<?php
class Time extends AppModel {
	var $name = 'Time';
	var $validate = array(
		'task_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'user_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'start' => array(
			'my_datetime' => array(
				'rule' => '/\b((0[1-9])|([1-2][0-9])|(3[0-1]))-((0[1-9])|(1[0-12]))-[0-9][0-9][0-9][0-9]\s(([0-1][0-9])|([2][0-3]))\:([0-5][0-9])\b/i',
				'message' => 'Start date must be in format: YYYY-DD-MM HH:MM'
			),
		),
		'finish' => array(
			'my_datetime' => array(
				'rule' => '/\b((0[1-9])|([1-2][0-9])|(3[0-1]))-((0[1-9])|(1[0-12]))-[0-9][0-9][0-9][0-9]\s(([0-1][0-9])|([2][0-3]))\:([0-5][0-9])\b/i',
				'message' => 'Finish date must be in format: YYYY-DD-MM HH:MM'
			),
		),
		'pause' => array(
			'my_time' => array(
				'rule' => '/\b(([0-1][0-9])|([2][0-3]))\:([0-5][0-9])\b/i',
				'message' => 'Pause time must be in format: HH:MM'
			),
		),
		'comment' => array(
			'notempty' => array(
				'rule' => array('notempty')
			),
		)
	);
	//The Associations below have been created with all possible keys, those that are not needed can be removed

	var $belongsTo = array(
		'Task' => array(
			'className' => 'Task',
			'foreignKey' => 'task_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'User' => array(
			'className' => 'User',
			'foreignKey' => 'user_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);
}
